#pragma once

#include <string>
#include "msgdef.h"

// C runtime header
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

// base header
#include "base/base.h"
#include "serial_port.h"
// duilib
#include "duilib/UIlib.h"
#include "tcp_client.h"

#include "lua_wraper.h"
#include "global.h"
#include <fstream>
#include "udp_libevent.h"
#include <istream>

class UdpForm :
	public ui::ChildBox,
	LuaBindInterface
{
public:
	UdpForm(ui::Window* hwnd, string url, uint32_t port, UdpDataGramLibevent* p);
	~UdpForm();
	virtual void Init() override;
	LuaDelegate* LuaVM();
	ui::RichEdit* m_rich_edit_2;

protected:
	void ShowDataInEdit(const char*) ;

private:
	ui::Label* m_label_1;
	ui::RichEdit* m_rich_edit_1;
	ui::RichEdit* m_rich_edit_3;
	ui::Button* m_button_1;
	ui::Button* m_button_2;
	ui::Button* m_button_3;
	ui::Button* m_button_4;


	std::ifstream mLuaFile;
	std::ofstream mLuaFileEdit;

	virtual void HandleMessage(ui::EventArgs& msg);
	std::string mLuaScript;
	std::string m_url;
	int m_port;
	LuaDelegate* mLua;
	UdpDataGramLibevent* mUdpPeer;
};


